<template>
  <view class="product-box-self" @tap="handleClick">
    <view class="product-fl">
      <image :src="car.img" mode="aspectFill" />
    </view>
    <view class="product-fr">
      <view class="product-title">{{ car.car_series_name }}</view>
      <view class="product-deploy">
        {{ car.car_brand_name + car.car_series_name + car.car_model_name }}
      </view>
      <view class="product-color">
        {{ car.emission_name }}｜{{
          car.appearance.map(i => i.value_title).join('/')
        }}｜销{{
          car.sale_area.length > 0
            ? car.sale_area.map(i => i.province_name + i.city_name).join('、')
            : '全国'
        }}
      </view>
      <view style="overflow: hidden;">
        <view class="product-price">{{ Number(car.price).toFixed(2) }}</view>
        <view class="product-unit">万</view>
        <view class="product-area">
          {{ formatAddress(car.car_address) }}
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { formatAddress } from '@utils/index'
export default {
  name: 'Car',
  props: {
    car: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {}
  },
  methods: {
    formatAddress,
    handleClick() {
      this.$emit('tap', this.car)
    }
  }
}
</script>

<style>
.product-box-self {
  padding: 24rpx 0;
  border-bottom: 2rpx solid rgba(238, 238, 238, 0.5);
  overflow: hidden;
}
.product-box-self .product-fl {
  float: left;
  width: 240rpx;
  height: 180rpx;
  position: relative;
}
.product-box-self .product-fl image {
  width: 100%;
  height: 100%;
  border-radius: 6rpx;
}
.product-box-self .product-fr {
  margin-left: 260rpx;
  position: relative;
}
.product-box-self .pro-img image {
  width: 100%;
}
.product-box-self .product-title {
  font-size: 32rpx;
  font-weight: bold;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.product-box-self .product-deploy {
  display: block;
  font-size: 28rpx;
  color: #333;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  margin: 6rpx 0;
}
.product-box-self .product-color {
  font-size: 24rpx;
  color: #999;
  margin-bottom: 10rpx;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.product-box-self .product-price {
  float: left;
  font-size: 36rpx;
  color: #ff0000;
  height: 40rpx;
  line-height: 40rpx;
  font-weight: bold;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.product-box-self .product-unit {
  float: left;
  font-size: 28rpx;
  color: #ff0000;
  margin-left: 6rpx;
  line-height: 40rpx;
  margin-top: 3rpx;
}
.product-box-self .product-area {
  float: right;
  width: 60%;
  font-size: 24rpx;
  color: #333;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  line-height: 40rpx;
  text-align: right;
}
.product-box-self .clear {
  clear: both;
}
</style>
